package com.headwind.properties;

/**
 * @author : Headwind
 * @version : 1.0
 * @date : Created in 2020/8/9
 * @description : 配置文件的读取
 */

import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.PostConstruct;

@RestController
@ConfigurationProperties(prefix = "com.headwind.person")
public class ReadConfigFileController {
    @Value("${com.headwind.email:default@163.com}")
    private String email;
    private String name;
    private String age;

    @GetMapping("/get-info")
    public String getConfigFileFields() {
        String userHome = System.getProperty("user.home");
        String mvnHome = System.getenv("MAVEN_HOME");
        System.out.println(userHome);
        System.out.println(mvnHome);
        return "姓名：" + name + "，年龄：" + age + "，邮件地址：" + email + "。";
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getAge() {
        return age;
    }

    public void setAge(String age) {
        this.age = age;
    }
}
